﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ToDo.Data
{
    class LinkSqlServer
    {

        public static string source = "Data Source=.;Initial Catalog=ToDo;Integrated Security=True";
        public static bool Add(string Sqlcommand)
        {
            using (SqlConnection connection = new SqlConnection(source))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(Sqlcommand, connection);
                
                int number = command.ExecuteNonQuery();
                if (number >= 1)
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
        }

        public static bool DoCommand(string Sqlcommand)
        {
            using (SqlConnection connection = new SqlConnection(source))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(Sqlcommand, connection);

                int number = command.ExecuteNonQuery();
                if (number >= 1)
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
        }

    }

}
